<{extend name="public/base"}>
<{block name="foot_source"}>
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">

<{/block}>
<{block name="content"}>
<!-- left column -->
<div class="col-md-12">
    <!-- general form elements -->
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title"><{$title}></h3>
        </div>
        <!-- /.box-header -->
        <!-- form start -->
        <form role="form" action="<?php echo url('admin/article_cate/update'); ?>" method="post">
            <div class="box-body">
                <div class="form-group">
                    <label for="title">分类标题</label>
                    <input type="text" class="form-control" id="title" name="title" value="<{$model.title}>" placeholder="请输入分类标题">
                </div>

                <div class="form-group">
                    <label for="seo_title">seo标题</label>
                    <input type="text" class="form-control" id="seo_title" name="seo_title"  value="<{$model.seo_title}>" placeholder="请输入seo标题">
                </div>
                <div class="form-group">
                    <label for="seo_desc">seo描述</label>
                    <input type="text" class="form-control" id="seo_desc" name="seo_desc" value="<{$model.seo_title}>" placeholder="请输入seo描述">
                </div>
                <div class="form-group">
                    <label for="seo_keywords">seo关键词</label>
                    <input type="text" class="form-control" id="seo_keywords" name="seo_keywords" value="<{$model.seo_title}>" placeholder="请输入seo关键词">
                </div>

                <div class="form-group">
                    <label for="seo_keywords">封面模板</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="index_template" name="index_template" value="<{$model.index_template}>" placeholder="选择封面模板">
                        <span class="input-group-addon open_template" data-title="封面模板"><i class="fa fa-search"></i></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="seo_keywords">列表模板</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="lists_template" name="lists_template" value="<{$model.lists_template}>" placeholder="选择列表模板">
                        <span class="input-group-addon  open_template" data-title="列表模板"><i class="fa  fa-search"></i></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="seo_keywords">内容模板</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="content_template" name="content_template" value="<{$model.content_template}>" placeholder="选择内容模板">
                        <span class="input-group-addon open_template" data-title="内容模板"><i class="fa fa-search"></i></span>
                    </div>
                </div>


                <input type="hidden" name="id" value="<{$model.id}>" />



                <div class="form-group">
                    <label for="seo_keywords">缩略图</label>
                    <div id="uploader" class="wu-example">
                        <!--用来存放文件信息-->
                        <input type="hidden" value="<{$model.cover}>" id="cover" name="cover" />
                        <div id="thelist" class="uploader-list"></div>
                        <div class="btns">
                            <img src="<{$model.cover}>" id="cover_show" />
                            <div id="" style="width:0;height:5px;"></div>
                            <div class="btn-group">
                                <button type="button" class="btn btn-primary " id="picker">上传图片</button>
                                <button type="button" class="btn btn-warning " id="picker_system">选择系统图片</button>
                            </div>

                        </div>
                    </div>
                </div>

            </div>
            <!-- /.box-body -->

            <div class="box-footer">
                <button type="submit" class="btn btn-primary">提交</button>
                <a href="<?php echo url('admin/article_cate/index'); ?>" class="btn btn-default">返回</a>
            </div>
        </form>
    </div>
    <!-- /.box -->
</div>


<!-- 弹出框 -->
<div class="modal fade" id="modal">
    <div class="modal-dialog" style="width: auto;" >
        <div class="modal-content" style="width: 60%;margin:0 auto;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="modal_title">封面模板</h4>
            </div>
            <div class="modal-body">
                <iframe id="modalIframe" width="100%" height="500px" frameborder="0"></iframe>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default " data-dismiss="modal">    关  闭    </button>
            </div>
        </div>
    </div>
</div>


<{/block}>
<{block name="foot_script"}>


<script type="text/javascript">
    var BASE_URL = '/static/webuploader';
    var uploader = WebUploader.create({
        // swf文件路径
        swf: BASE_URL + '/js/Uploader.swf',
        // 文件接收服务端。
        server: '/admin/api/upload',
        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#picker',
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });

    // 当有文件被添加进队列的时候
    uploader.on( 'fileQueued', function( file ) {
        uploader.upload();
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on( 'uploadSuccess', function( file,data ) {
        console.log( data._raw );
        console.log(data.ext);
        console.log(data.filename);
        console.log(data.name);
        $("#cover").val(data.url);
        $("#cover_show").attr('src',data.url);
    });


    $(function(){
        var that;
        var action = 1; //1 获取模板 2 获取图片
        $(".open_template").click(function(){
            that = this;
            action = 1;
            var src = '/admin/template/lists.html';
            var title = $(this).data('title');
            $("#modal_title").html(title);
            $("#modalIframe").attr('src',src);
            $("#modal").modal();
        });

        window.modalCallback = function(id){
            if(action == 1){
                $.get('/admin/template/getTemplate',{id:id},function(data){
                    $(that).parent().find('input').val(data.data.path);
                    $("#modal").modal("toggle");
                });
            }else{
                $.get('/admin/upload/getImage',{id:id},function(data){
                    $("#cover").val(data.data.url);
                    $("#cover_show").attr('src',data.data.url);
                    $("#modal").modal("toggle");
                });
            }


        };

        $("#picker_system").click(function(){
            action = 2;
            var src = '/admin/upload/imageList.html';
            var title = $(this).data('title');
            $("#modal_title").html(title);
            $("#modalIframe").attr('src',src);
            $("#modal").modal();
        });


    });

</script>
<{/block}>

